import { createRouter, createWebHistory } from "vue-router";
// 登录
import SelectView from "../views/LogView/SelectView.vue";
import CustomerLoginView from "../views/LogView/CustomerLoginView.vue";
import LoginView from "../views/LogView/ManangerLoginView.vue";
import RegisterView from "../views/LogView/RegisterView.vue";

import DashboardView from "../views/ManagerView/DashboardView.vue";
import CustomerView from "../views/ManagerView/CustomerView.vue";
import CardView from "../views/ManagerView/CardView.vue";
import DepositView from "../views/ManagerView/DepositView.vue";
import TradeView from "../views/ManagerView/TradeView.vue";

import CustomerDashboard from "../views/CustomerView/CustomerDashboard.vue";
import CustomerThing from "../views/CustomerView/CustomerThing.vue";
import Transaction from "../views/CustomerView/TransactionView.vue";
import BalanceQuery from "../views/CustomerView/BalanceQuery.vue";
import CardManagement from "../views/CustomerView/CardManagement.vue";
import TransactionHistory from "../views/CustomerView/TransactionHistory.vue";
import PasswordChange from "../views/CustomerView/PasswordChange.vue";
import Transfer from "../views/CustomerView/TransferView.vue";

const routes = [
  {
    path: "/",
    redirect: "/select-login", // 根路径重定向到登录类型选择页
  },
  {
    path: "/select-login",
    name: "SelectLogin",
    component: SelectView,
  },
  {
    path: "/customer-login",
    name: "CustomerLogin",
    component: CustomerLoginView,
  },
  {
    path: "/login",
    name: "Login",
    component: LoginView, // 管理员登录页
  },
  {
    path: "/register",
    name: "Register",
    component: RegisterView,
  },

  {
    path: "/testcustomer",
    name: "testcustomer",
    component: CustomerView,
  },
  {
    path: "/testcard",
    name: "testcard",
    component: CardView,
  },
  {
    path: "/testdeposit",
    name: "testdeposit",
    component: DepositView,
  },
  {
    path: "/testtrade",
    name: "testtrade",
    component: TradeView,
  },
  {
    path: "/testDashboard",
    name: "testDashboard",
    component: DashboardView,
  },
  {
    path: "/ManagerDashboard",
    name: "ManagerDashboard",
    component: DashboardView,
    children: [
      { path: "customer", name: "Customer", component: CustomerView },
      { path: "card", name: "Card", component: CardView },
      { path: "deposit", name: "Deposit", component: DepositView },
      { path: "trade", name: "Trade", component: TradeView },
    ],
  },
  {
    path: "/CustomerDashboard",
    name: "CustomerDashboard",
    component: CustomerDashboard,
    children: [
      { path: "", redirect: "CustomerDashboard/customerthing" },
      {
        path: "customerthing",
        name: "CustomerThing",
        component: CustomerThing,
      },
      { path: "transaction", name: "Transaction", component: Transaction },
      { path: "balancequery", name: "BalanceQuery", component: BalanceQuery },
      {
        path: "cardmanagement",
        name: "CardManagement",
        component: CardManagement,
      },
      {
        path: "transactionhistory",
        name: "TransactionHistory",
        component: TransactionHistory,
      },
      {
        path: "passwordchange",
        name: "PasswordChange",
        component: PasswordChange,
      },
      {
        path: "transfer",
        name: "Transfer",
        component: Transfer,
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
